package cn.sunjinxin.trade.application.point.preorder;

import cn.sunjinxin.savior.ext.anno.ExtensionPoint;
import cn.sunjinxin.trade.domain.ability.PreorderAbility;
import cn.sunjinxin.trade.domain.model.ProductSku;
import cn.sunjinxin.trade.infrastructure.external.ProductRpcService;

import javax.annotation.Resource;

/**
 * @author issavior
 */
@ExtensionPoint(bizCode = "api", scenario = "inventory")
public class ApiPreorderPoint extends PreorderAbility {

    @Resource
    private ProductRpcService productRpcService;

    @Override
    public Boolean preorder(ProductSku request) {
        // 库存预扣减
        return productRpcService.deductInventory(request.getProductSkuId());
    }

    @Override
    public Boolean replenishment(ProductSku request) {
        return productRpcService.replenishmentInventory(request.getProductSkuId());
    }
}
